<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/8/18
 * Time: 14:17
 */
namespace  app\admin\controller;
use app\admin\model\User;
use think\Config;

class  Login extends Base {
  /*
  *登录界面
  */
  public function index(){
     $webroot=config('conist');
     $this->assign('webroot',$webroot);
     return $this->fetch();
  }
    /**
     * 登录
     */
   public  function  login(){
       $validate = validate('User');
       $data = new User($_REQUEST);
       $data = $data->getData();
       if(!$this->checkcaptcha(input('post.verify'))){
        $this->error('验证码错误');
       }
       if (!$validate->check($data)) {
           $this->error($validate->getError());
       }
       $usermodel=new User();
       $res =$usermodel->allowField(true)->save($data);
       if($res){
           $this->success('登陆成功','menu/index');
       }else{
           $this->error('失败');
       }
   }
}